import React from 'react';
import {Modal} from 'antd';

import './scss/modal.scss';

class RCModal extends React.Component {

    modalFooter() {
      let {btns=['确认','取消'], disable=false, onOk=()=>{console.log('确定的操作')}, onCancel=()=>console.log('取消的操作')} = this.props;
      let confirm = (
        <span key='confirm'
          className={`footer-btn ${!disable?'':'disabled'}`}
          onClick={() => !disable ? onOk() : 0}
        >{btns[0]}</span>
      );
      let cancal = (
        <span key='cancal'
          className="footer-btn cancal"
          onClick={() => onCancel()}
        >{btns[1]}</span>
      );

      return [confirm, cancal];
    }

    render() {
        let {title='', width=520, centered=false, visible=false, footer=this.modalFooter(), children=null, onCancel=()=>console.log('取消的操作')} = this.props;
        let property = {title, visible, width, centered, footer, onCancel};

        return (
            <Modal {...property}>
              {children}
            </Modal>
        )
    }
}

export default RCModal;